package com.gerry.demo;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestStudent {
	public static void main(String[] args) {
		// 创建Stduent对象
		// Student stu = new Student();
		
		// 实例化Spring容器(把容器中配置需要管理的bean实例创建存储到Map集合中)
		// Map<String,Object> => key = bean对应id/name , value = class属性值反射生成对象实例
		ApplicationContext ctx = new ClassPathXmlApplicationContext("container.xml");
		// 获取容器中创建对象实例
		System.out.println(ctx.getBean("stu"));
		System.out.println(ctx.getBean("stu1"));
		System.out.println("===============================");
		Student student = (Student) ctx.getBean("stu2");
		student.printMessage();
	}
}
